﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using EnvironmentManagerSystem.MODE;
using EnvironmentManagerSystem.BLL;
using EnvironmentManagerSystem.Utility;
using System.Collections;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Text;
using System.Drawing;


namespace EnvironmentManagerSystem.HuanJing
{
    public partial class HuanJing_XiangMu : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StfInfo.ReSession()) return; if (!IsPostBack)
            {

                //txtStandard.Text = "0.8";
                //txtApproved.Text = "0.8";
                Button5.Enabled = false;
                binds();
                DropDownListBind();
                //项目负责人
                BindFuzeren(string.Empty);
                DisplayExplain();
                //复审会议
                tb.Visible = cbofs.Checked;
                Q();
                CheckBox2.Visible = true;
                ShowProcessing();
            }
        }

        #region 显示当前流程状态
        private void ShowProcessing()
        {
            bool Leader = Session["roleid"].ToString().Contains("中心领导");
            bool Acceptance = Session["roleid"].ToString().Contains("受理人");
            bool ProHead = Session["roleid"].ToString().Contains("项目负责人");
            bool DepHead = Session["roleid"].ToString().Contains("部门负责人");

            DataTable dt = XIANGMU.GetProjectInfo();
            if (dt.Rows.Count == 0)
                return;

            #region 权限验证
            if (Leader == true)
            {
                if (dt.Rows[0]["hyxsbqd"].ToString().Trim() == "2")
                {
                    CheckBox2.Visible = false;
                    cb2.Visible = true;
                    cb2.ForeColor = Color.Red;
                }
                else
                {
                    CheckBox2.Visible = false;
                    cb2.Visible = false;
                }
            }

            #endregion
            LabLog.Text = dt.Rows[0]["LogTrace"].ToString().Trim();
            shouli.Text = dt.Rows[0]["ShouLiTrace"].ToString().Trim();//项目受理痕迹
            //if (dt.Rows[0]["xiangmushouliren"].ToString().Trim() != string.Empty)
            //    shouli.Text = string.Format("已受理({0}){1}", dt.Rows[0]["xiangmushouliren"].ToString(), dt.Rows[0]["xiangmushoulishijian"].ToString());
            labDepartment.Text = dt.Rows[0]["DistributionTrace"].ToString().Trim();
            labConfirmHead.Text = dt.Rows[0]["ResponTrace"].ToString().Trim();
            labConfirmLook.Text = dt.Rows[0]["LookTrace"].ToString().Trim();
            labConfirmMeeting.Text = dt.Rows[0]["ExpertMeetingTrace"].ToString().Trim();
            lbiyichuli.Text = dt.Rows[0]["OpinionTrace"].ToString().Trim();
            labXiangMuKaoPing.Text = dt.Rows[0]["AppraisalTrace"].ToString().Trim();
            labReportOK.Text = dt.Rows[0]["ReportingTrace"].ToString().Trim();
            //显示数据

            txtLog.Text = dt.Rows[0]["ProjectLog"].ToString();
            if (dt.Rows[0]["nanduxishu"].ToString().Trim() != string.Empty)
            {
                txtDifficulty.ClearSelection();
                txtDifficulty.Items.FindByText(dt.Rows[0]["nanduxishu"].ToString().Trim()).Selected = true;
            }
            if (dt.Rows[0]["hangyexishu"].ToString().Trim() != string.Empty)
            {
                txtIndustry.ClearSelection();
                txtIndustry.Items.FindByText(dt.Rows[0]["hangyexishu"].ToString().Trim()).Selected = true;
            }


            //if (dt.Rows[0]["hedinghetongjine"].ToString() != string.Empty)
            //    LinkButton4.Visible = true;
            //else
            //    LinkButton4.Visible = false;
            if (dt.Rows[0]["pinggubaogaoURL"].ToString() != string.Empty)
                LinkButton5.Visible = true;
            else
                LinkButton5.Visible = false;
            #region MyRegion

            //下载合同按钮
            if (Leader == true)
            {
                txtIndustry.Enabled = true;//行业调整系数
                txtDifficulty.Enabled = true;//敏感程度调整系数
                txtStandard.Enabled = true;
            }
            else
            {
                if (dt.Rows[0]["hdpgjer"].ToString().Trim() != string.Empty)
                {

                    txtIndustry.Enabled = false;//行业调整系数
                    txtDifficulty.Enabled = false;//敏感程度调整系数
                    txtStandard.Enabled = false;
                }
                else
                {
                    txtIndustry.Enabled = true;//行业调整系数
                    txtDifficulty.Enabled = true;//敏感程度调整系数
                    txtStandard.Enabled = true;
                }
            }
            //下载合同按钮
            if (dt.Rows[0]["hdpgjer"].ToString().Trim() != string.Empty)
            {
                LinkButton4.Visible = true;
                Button5.Enabled = true;
            }
            else
            {
                LinkButton4.Visible = false;
                Button5.Enabled = false;
            }
            if (dt.Rows[0]["hyxsbqd"].ToString().Trim() == "2")
                CheckBox2.Checked = true;
            else
                CheckBox2.Checked = false;
            if (dt.Rows[0]["hesuanren"].ToString().Trim() != string.Empty)
                txtApprovedPeople.Text = dt.Rows[0]["hesuanren"].ToString();
            else
                txtApprovedPeople.Text = "";


            //txtStandard.Text = dt.Rows[0]["biaozhunhetongjine"].ToString();
            if (dt.Rows[0]["biaozhunhetongjine"].ToString().Trim() != string.Empty)
            {
                txtStandard.Text = dt.Rows[0]["biaozhunhetongjine"].ToString();
                //txtApprovedPeople.Text = dt.Rows[0]["hesuanren"].ToString();
            }
            else
                NewMethod2();
            //txtApproved.Text = dt.Rows[0]["hedinghetongjine"].ToString();
            if (dt.Rows[0]["hedinghetongjine"].ToString().Trim() != string.Empty)
                txtApproved.Text = dt.Rows[0]["hedinghetongjine"].ToString();
            else
                NewMethod2();
            #endregion
            //if (dt.Rows[0]["pingguyijianURL"].ToString() != string.Empty)
            //    LinkButton7.Visible = true;
            //else
            //    LinkButton7.Visible = false;
            //if (dt.Rows[0]["fushenpingguyijianURL"].ToString() != string.Empty && cbofs.Checked == true)
            //    LinkButton6.Visible = true;
            //else
            //    LinkButton6.Visible = false;
            //txtApprovedPeople.Text = dt.Rows[0]["hesuanren"].ToString();


            if (dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim() != string.Empty)
            {
                txtbumen.ClearSelection();
                txtbumen.Items.FindByText(dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim()).Selected = true;
                BindFuzeren(txtbumen.Text);
            }
            hantacha.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["hantacha"]));
            hanhuiyi.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["hanhuiyi"]));
            lvsetongdao.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["lvsetongdao"]));
            biangengxiangmu.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["biangengxiangmu"]));
            //预审项目
            //yushenxiangmu.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["yushenxiangmu"]));
            if (dt.Rows[0]["pingshenxiangmufuzeren"].ToString().Trim() != string.Empty && dt.Rows[0]["pingshenxiangmufuzeren"] != null)
            {
                ddlHead.ClearSelection();
                ddlHead.Items.FindByText(dt.Rows[0]["pingshenxiangmufuzeren"].ToString().Trim()).Selected = true;
            }
            //if (dt.Rows[0]["tachaquerentuihui"].ToString().Trim() == "1")//如果项目负责人退回
            //{
            txtLookDate.Text = dt.Rows[0]["tachariqi"].ToString().Trim();
            txtLookPlace.Text = dt.Rows[0]["tachadidian"].ToString().Trim();
            input2zhuanjia.Value = dt.Rows[0]["tachazhuanjia"].ToString().Trim();
            txtMeetingTime.Text = dt.Rows[0]["zhuanjiahuiyichuliriqi"].ToString().Trim();
            if (dt.Rows[0]["zhuanjiahuiyiriqiflag"].ToString().Trim() == "1")
                am0.Checked = true;
            if (dt.Rows[0]["zhuanjiahuiyiriqiflag"].ToString().Trim() == "2")
                pm0.Checked = true;

            txtMeetingPlace.Text = dt.Rows[0]["zhuanjiahuiyididian"].ToString().Trim();
            txtMeetingExpert.Text = dt.Rows[0]["zhuanjiahuiyizhuanjian"].ToString().Trim();
            //txtbeizhu.Text = dt.Rows[0]["yijianbeizhu"].ToString().Trim();
            if (dt.Rows[0]["huiyipingshenjieguo"].ToString().Trim() != string.Empty)
            {
                ddlResult.ClearSelection();
                ddlResult.Items.FindByText(dt.Rows[0]["huiyipingshenjieguo"].ToString().Trim()).Selected = true;
            }
            txtshuoming.Text = dt.Rows[0]["buhegeshuoming"].ToString().Trim();
            string[] ProjectState = dt.Rows[0]["pingguyijianxiangmuzhuangtai"].ToString().Trim().Split(',');
            CheckBoxList1.ClearSelection();
            foreach (ListItem item in CheckBoxList1.Items)
            {
                foreach (string state in ProjectState)
                {
                    if (item.Value == state)
                        item.Selected = true;
                }
            }

            string[] TiaoKuan = dt.Rows[0]["buhegetiaokuan"].ToString().Trim().Split(',');
            listtiaokuan.ClearSelection();
            foreach (ListItem item in listtiaokuan.Items)
            {
                foreach (string tiaokuan in TiaoKuan)
                {
                    if (item.Value == tiaokuan)
                        item.Selected = true;
                }
            }
            time.Text = dt.Rows[0]["pingguyijianhuiyiriqi"].ToString().Trim();
            if (dt.Rows[0]["shangwu"].ToString().Trim() != string.Empty)
                am.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["shangwu"]));
            if (dt.Rows[0]["xiawu"].ToString().Trim() != string.Empty)
                pm.Checked = Convert.ToBoolean(Convert.ToInt32(dt.Rows[0]["xiawu"]));
            txtdidian.Text = dt.Rows[0]["pingguyijianhuiyididian"].ToString().Trim();
            if (dt.Rows[0]["fushenhuiyipingshenjieguo"].ToString().Trim() != string.Empty)
                ddlfushenResult.Items.FindByText(dt.Rows[0]["fushenhuiyipingshenjieguo"].ToString().Trim()).Selected = true;
            TextBox22.Text = dt.Rows[0]["chugaokaoping"].ToString().Trim();
            TextBox23.Text = dt.Rows[0]["zhonggaokaoping"].ToString().Trim();
            //环评单位考评
            //TextBox24.Text = dt.Rows[0]["huanpingdanweikaoping"].ToString().Trim();
            foreach (ListItem item in cblistMaterial.Items)
            {
                foreach (string MaterialCode in dt.Rows[0]["huizongshangbaoshumiancailiao"].ToString().Trim().Split(','))
                {
                    if (item.Value == MaterialCode)
                        item.Selected = true;
                }
            }
            //}

            looking.Visible = hantacha.Checked;
            meeting.Visible = hanhuiyi.Checked;

            //流程限制
            //限制项目受理、项目删除、项目退回按钮的可用状态
            if (dt.Rows[0]["shoulituihuishanchu"].ToString().Trim() == string.Empty && (Leader == true || Acceptance == true))
            {
                Button4.Enabled = true;
                //if (dt.Rows[0]["hesuanren"].ToString().Trim() == string.Empty)
                //    Button5.Enabled = false;
                //else
                //    Button5.Enabled = true;
                Button6.Enabled = true;
                Button7.Enabled = true;
            }
            else
            {
                Button4.Enabled = false;
                //Button5.Enabled = false;
                Button6.Enabled = false;
                Button7.Enabled = false;
            }

            //根据角色的不同限制项目负责模块按钮的可用状态
            if (DepHead == true)
            {
                bool result = false;
                if (dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim() != string.Empty)
                    result = ExecutiveDepartmentService.WhetherBelong(int.Parse(Session["ID"].ToString()), dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim());
                if (dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim() != string.Empty && result == true && (dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() == ""
                    || (dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() == "1" && !XIANGMU.WhetherLeader(dt.Rows[0]["xiangmufuzequerenren"].ToString().Trim()))))
                {
                    Button9.Enabled = true;
                    Button10.Enabled = true;
                }
                else
                {
                    Button9.Enabled = false;
                    Button10.Enabled = false;
                }
            }
            //项目负责人模块按钮状态
            if (DepHead == true || ProHead == true)
            {
                if (dt.Rows[0]["pingshenxiangmufuzeren"].ToString().Trim() == Session["UserName"].ToString() && (dt.Rows[0]["tachaquerentuihui"].ToString().Trim() != "0" ||
                    (dt.Rows[0]["tachaquerentuihui"].ToString().Trim() == "0" && dt.Rows[0]["tachaquerenren"].ToString().Trim() != Session["UserName"].ToString())))
                {
                    //现场踏查按钮状态

                    if (dt.Rows[0]["tachaquerentuihui"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["tachaquerenren"].ToString().Trim()))
                    {
                        Button11.Enabled = false;
                        Button13.Enabled = false;
                    }
                    else
                    {
                        Button11.Enabled = true;
                        Button13.Enabled = true;
                    }
                    //专家会议按钮状态

                    if (dt.Rows[0]["huiyiqueren"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["zhuanjiahuiyiquerenren"].ToString().Trim()))
                        Button16.Enabled = false;
                    else
                        Button16.Enabled = true;
                    //评估意见按钮状态
                    if (dt.Rows[0]["queren"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["pingguyijianchuliren"].ToString().Trim()))
                        Button19.Enabled = false;
                    else
                        Button19.Enabled = true;
                    //项目考评按钮状态
                    if (XIANGMU.WhetherLeader(dt.Rows[0]["xiangmukaopingchuliren"].ToString().Trim()))
                        Button21.Enabled = false;
                    else
                        Button21.Enabled = true;
                    //汇总状态按钮状态
                    if (dt.Rows[0]["reportstate"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["reportpeople"].ToString().Trim()))
                    {
                        Button22.Enabled = false;
                        Button14.Enabled = false;
                    }
                    else
                    {
                        Button22.Enabled = true;
                        Button14.Enabled = true;
                    }
                    //LinkButton1.Visible = true;
                    //LinkButton2.Visible = true;
                    LinkButton3.Visible = true;
                }
                else
                {
                    //LinkButton1.Visible = false;
                    //LinkButton2.Visible = false;
                    LinkButton3.Visible = false;
                    Button11.Enabled = false;
                    Button13.Enabled = false;
                    Button16.Enabled = false;
                    Button19.Enabled = false;
                    Button21.Enabled = false;
                    Button22.Enabled = false;
                    Button14.Enabled = false;
                }
            }
            if (Leader == true)
            {
                //LinkButton1.Visible = true;
                //LinkButton2.Visible = true;
                LinkButton3.Visible = true;
                Button10.Enabled = false;
                Button11.Enabled = false;
                if (dt.Rows[0]["shoulituihuishanchu"].ToString().Trim() == "1" && dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() != "1")
                {
                    Button8.Enabled = true;
                    hantacha.Enabled = true;
                    hanhuiyi.Enabled = true;
                }
                else
                {
                    Button8.Enabled = false;
                    hantacha.Enabled = false;
                    hanhuiyi.Enabled = false;
                }
                if (dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim() != string.Empty && dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() != "0" &&
                    (dt.Rows[0]["tachaquerentuihui"].ToString().Trim() != "1" && dt.Rows[0]["xiangmukaopingchuliren"].ToString().Trim() == string.Empty &&
                    dt.Rows[0]["huiyiqueren"].ToString().Trim() != "1" && dt.Rows[0]["queren"].ToString().Trim() != "1" &&
                    dt.Rows[0]["reportstate"].ToString().Trim() != "1" && dt.Rows[0]["shangbaocailiaoquerenren"].ToString().Trim() == string.Empty))
                    ddlHead.Enabled = true;
                else
                    ddlHead.Enabled = false;
                if (dt.Rows[0]["fenpeizhixingbumen"].ToString().Trim() != string.Empty)
                    Button9.Enabled = true;
                else
                    Button9.Enabled = false;
                //现场踏查按钮状态
                //if (dt.Rows[0]["hantacha"].ToString().Trim() == "1")
                //{
                if (dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() == "1")
                    Button13.Enabled = true;
                else
                    Button13.Enabled = false;
                //}
                //专家会议按钮状态
                //if (dt.Rows[0]["hanhuiyi"].ToString().Trim() == "1")
                //{
                if ((dt.Rows[0]["hantacha"].ToString().Trim() == "1" && dt.Rows[0]["tachaquerentuihui"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["tachaquerenren"].ToString().Trim()))
                    || (dt.Rows[0]["hantacha"].ToString().Trim() != "1" && dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() == "1"))
                    Button16.Enabled = true;
                else
                    Button16.Enabled = false;
                //}
                //评估意见按钮状态
                if ((dt.Rows[0]["huiyiqueren"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["zhuanjiahuiyiquerenren"].ToString().Trim()))
                    || (dt.Rows[0]["hantacha"].ToString().Trim() != "1" && dt.Rows[0]["hanhuiyi"].ToString().Trim() != "1" && dt.Rows[0]["fuzetuihuiqueren"].ToString().Trim() == "1")
                    || (dt.Rows[0]["hantacha"].ToString().Trim() == "1" && dt.Rows[0]["hanhuiyi"].ToString().Trim() != "1"
                    && dt.Rows[0]["tachaquerentuihui"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["tachaquerenren"].ToString().Trim())))
                    Button19.Enabled = true;
                else
                    Button19.Enabled = false;
                //项目考评按钮状态
                if (dt.Rows[0]["queren"].ToString().Trim() == "1" && XIANGMU.WhetherLeader(dt.Rows[0]["pingguyijianchuliren"].ToString().Trim()))
                    Button21.Enabled = true;
                else
                    Button21.Enabled = false;
                //汇总状态按钮状态
                if (XIANGMU.WhetherLeader(dt.Rows[0]["xiangmukaopingchuliren"].ToString().Trim()))
                {
                    Button22.Enabled = true;
                    Button14.Enabled = true;
                }
                else
                {
                    Button22.Enabled = false;
                    Button14.Enabled = false;
                }
            }
            else
            {
                Button8.Enabled = false;
                hantacha.Enabled = false;
                hanhuiyi.Enabled = false;
            }

        }
        #endregion

        #region Q
        private void Q()
        {
            //行业系数,难度系数
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "1"))
            {
                txtDifficulty.Enabled = true;
                txtIndustry.Enabled = true;
            }
            else
            {
                txtDifficulty.Enabled = false;
                txtIndustry.Enabled = false;
            }
            //项目预审,生成合同
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "2"))
            {
                //有个项目预审权限预留
                Button4.Enabled = true;
            }
            else
            {
                //有个项目预审权限预留
                Button4.Enabled = false;
            }
            //正式受理
            //if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "3"))
            //{
            //    Button5.Enabled = true;
            //}
            //else
            //{
            //    Button5.Enabled = false;
            //}
            //退回项目
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "4"))
            {
                Button6.Enabled = true;
            }
            else
            {
                Button6.Enabled = false;
            }
            //项目负责退回按钮===任务退回
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "5"))
            {
                Button10.Enabled = true;
            }
            else
            {
                Button10.Enabled = false;
            }
            //现场踏查不包含设定日期
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "6"))
            {
                Button13.Enabled = true;
                Button11.Enabled = true;
            }
            else
            {
                Button13.Enabled = false;
                Button11.Enabled = false;
            }
            //专家会议不包含日期
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "7"))
            {
                Button16.Enabled = true;
            }
            else
            {
                Button16.Enabled = false;
            }
            //评估意见
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "8"))
            {
                Button19.Enabled = true;
                Button18.Enabled = true;
            }
            else
            {
                Button19.Enabled = false;
                Button18.Enabled = false;
            }
            //项目考评
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "9"))
            {
                Button21.Enabled = true;
            }
            else
            {
                Button21.Enabled = false;
            }
            //材料汇总（模块未实现）
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "10"))
            {

            }
            else
            {

            }
            //选取项目负责人
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "11"))
            {
                //ddlHead.Enabled = true;
                Button9.Enabled = true;
            }
            else
            {
                //ddlHead.Enabled = false;
                Button9.Enabled = false;
            }
            //审批流程确认（确认后项目负责人无权修改，但部门负责人依然有权修改） =============================================预留
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "12"))
            {

            }
            else
            {

            }
            //部门分配
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "13"))
            {
                Button8.Enabled = true;
            }
            else
            {
                Button8.Enabled = false;
            }
            //确认踏查日期
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "14"))
            {
                Button12.Enabled = true;
            }
            else
            {
                Button12.Enabled = false;
            }

            //确认会议日期
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "15"))
            {
                Button15.Enabled = true;
            }
            else
            {
                Button15.Enabled = false;
            }
            //审批流程确认（确认后其他角色无权修改，但中心领导依然有权修改）=========================================预留
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "16"))
            {

            }
            else
            {

            }
            //核定评估金额
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "17"))
            {
                txtApproved.Enabled = true;
                Button3.Enabled = true;
            }
            else
            {
                txtApproved.Enabled = false;
                Button3.Enabled = false;
            }
            //汇总上报
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "12"))
            {
                Button14.Enabled = true;
            }
            else
            {
                Button14.Enabled = false;
            }
            //汇总上报
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "16"))
            {
                Button14.Enabled = true;
            }
            else
            {
                Button14.Enabled = false;
            }
            //汇总上报保存
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "33"))
            {
                Button22.Enabled = true;
            }
            else
            {
                Button22.Enabled = false;
            }
            //项目日志
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "20"))
            {
                Button2.Enabled = true;
            }
            else
            {
                Button2.Enabled = false;
            }
            //项目删除
            if (BLL.Role.GetQ(int.Parse(Session["ID"].ToString()), "32"))
            {
                Button7.Enabled = true;
            }
            else
            {
                Button7.Enabled = false;
            }
        }
        #endregion

        #region 核算金额/核定评估金额
        #region 核算金额
        protected void Button4_Click(object sender, EventArgs e)
        {
            if (txtStandard.Text == "")
                Jscript.Alert("核算金额为空!", this);
            else
            {
                NewMethod0();
                if (BLL.HuanJing.EditTable("UPDATE tbs001_developprojectbasicinfo t SET t.nanduxishu='" + txtDifficulty.Text.Trim() + "',t.hangyexishu='" + txtIndustry.Text.Trim() + "',t.biaozhunhetongjine='" + txtStandard.Text.Trim() + "',t.hesuanren='" + Session["UserName"].ToString() + "',t.hetongdate='" + DateTime.Now.ToString("yyyy年MM月dd日") + "',t.hedinghetongjine='" + txtApproved.Text.Trim() + "',ShouLiTrace =CONCAT(ShouLiTrace,'|" + HttpContext.Current.Session["UserName"].ToString() + "已于" + DateTime.Now.ToString("yyyy年MM月dd日") + "进行核算金额操作)') WHERE t.ProjectName LIKE '" + Session["pjName"].ToString() + "';") > 0)
                {
                    Jscript.Alert("核算金额成功!", this);
                    ShowProcessing();
                }
                else
                    Jscript.Alert("核算金额失败!", this);
            }
        }
        #endregion

        #region 核定评估金额
        protected void Button3_Click(object sender, EventArgs e)
        {
            if (txtApproved.Text == "")
                Jscript.Alert("核定评估金额为空!", this);
            else
            {
                NewMethod1();
                string Approved = txtApproved.Text.ToString();
                //HttpContext.Current.Session["UserName"].ToString(), DateTime.Now.Date.ToString("yyyy-MM-dd"),
                //if (BLL.HuanJing.EditTable("UPDATE tbs001_developprojectbasicinfo t SET t.hedinghetongjine='" + txtApproved.Text.Trim() + "',t.hdpgjer ='" + Session["UserName"].ToString() + "' WHERE t.ProjectName LIKE '" + Session["pjName"].ToString() + "' ") > 0)
                if (BLL.HuanJing.EditTable("UPDATE tbs001_developprojectbasicinfo t SET t.hedinghetongjine='" + Approved + "',t.hdpgjer ='" + Session["UserName"].ToString() + "',t.nanduxishu='" + txtDifficulty.Text.Trim() + "',t.hangyexishu='" + txtIndustry.Text.Trim() + "',t.biaozhunhetongjine='" + txtStandard.Text.Trim() + "',ShouLiTrace =CONCAT(ShouLiTrace,'|" + HttpContext.Current.Session["UserName"].ToString() + "已于" + DateTime.Now.ToString("yyyy年MM月dd日") + "进行评定评估金额操作)') WHERE t.ProjectName LIKE '" + Session["pjName"].ToString() + "' ") > 0)
                {
                    Jscript.Alert("核定成功,合同生成成功!", this);
                    ShowProcessing();
                }
                else
                    Jscript.Alert("核定失败!,合同生成失败", this);
            }
        }
        #endregion

        #endregion

        #region NewMethod1
        private void NewMethod0()
        {
            if (Session["rd"] != null || Session["td"] != null)
            {
                if (Session["tb"].ToString() == "")
                {
                    Jscript.Alert("本项目还没有总投资数，无法计算！", this);
                }
                else
                {
                    int type = (int)Session["rd"];//这个是用来判断是报告书还是报告表 这里我定义报告书为1
                    double money = Convert.ToDouble(Session["tb"]);		//这个是项目资金
                    double returnMoney = 0;	//这个是返回的项目金额
                    double Industry = Convert.ToDouble(txtIndustry.SelectedItem.Text.Trim());//行业系数
                    double Difficulty = Convert.ToDouble(txtDifficulty.SelectedItem.Text.Trim());//难度系数
                    if (type == 1)
                    {
                        if (money * 0.0001 >= 0 && money * 0.0001 <= 0.3)
                        {
                            returnMoney = 2.333 * money * 0.0001 + 0.8;		//先用亿计算
                            //returnMoney = returnMoney * 10000;	//计算之后乘以10000吧亿化成万的单位
                        }
                        else if (money * 0.0001 > 0.3 && money * 0.0001 <= 2)
                        {
                            returnMoney = 0.882 * money * 0.0001 + 1.235;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 2 && money * 0.0001 <= 10)
                        {
                            returnMoney = 0.5 * money * 0.0001 + 2;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 10 && money * 0.0001 <= 50)
                        {
                            returnMoney = 0.05 * money * 0.0001 + 6.5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 50 && money * 0.0001 <= 100)
                        {
                            returnMoney = 0.08 * money * 0.0001 + 5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 100)
                        {
                            // returnMoney = 13 * 10000;
                            returnMoney = 13;
                        }
                    }
                    else
                    {
                        if (money * 0.0001 >= 0 && money * 0.0001 <= 0.3)
                        {
                            returnMoney = money * 0.0001 + 0.5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 0.3 && money * 0.0001 <= 2)
                        {
                            returnMoney = 0.412 * money * 0.0001 + 0.676;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 2 && money * 0.0001 <= 10)
                        {
                            returnMoney = 0.0625 * money * 0.0001 + 1.375;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 10 && money * 0.0001 <= 50)
                        {
                            //returnMoney = 2 * 10000;
                            returnMoney = 2;
                        }
                    }
                    txtStandard.Text = Math.Round(returnMoney * Industry * Difficulty, 2, MidpointRounding.AwayFromZero).ToString();
                    txtApproved.Text = Math.Round(returnMoney * Industry * Difficulty, 2, MidpointRounding.AwayFromZero).ToString();
                }
            }
        }
        private void NewMethod1()
        {
            if (Session["rd"] != null || Session["td"] != null)
            {
                if (Session["tb"].ToString() == "")
                {
                    Jscript.Alert("本项目还没有总投资数，无法计算！", this);
                }
                else
                {
                    int type = (int)Session["rd"];//这个是用来判断是报告书还是报告表 这里我定义报告书为1
                    double money = Convert.ToDouble(Session["tb"]);		//这个是项目资金
                    double returnMoney = 0;	//这个是返回的项目金额
                    double Industry = Convert.ToDouble(txtIndustry.SelectedItem.Text.Trim());//行业系数
                    double Difficulty = Convert.ToDouble(txtDifficulty.SelectedItem.Text.Trim());//难度系数
                    if (type == 1)
                    {
                        if (money * 0.0001 >= 0 && money * 0.0001 <= 0.3)
                        {
                            returnMoney = 2.333 * money * 0.0001 + 0.8;		//先用亿计算
                            //returnMoney = returnMoney * 10000;	//计算之后乘以10000吧亿化成万的单位
                        }
                        else if (money * 0.0001 > 0.3 && money * 0.0001 <= 2)
                        {
                            returnMoney = 0.882 * money * 0.0001 + 1.235;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 2 && money * 0.0001 <= 10)
                        {
                            returnMoney = 0.5 * money * 0.0001 + 2;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 10 && money * 0.0001 <= 50)
                        {
                            returnMoney = 0.05 * money * 0.0001 + 6.5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 50 && money * 0.0001 <= 100)
                        {
                            returnMoney = 0.08 * money * 0.0001 + 5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 100)
                        {
                            // returnMoney = 13 * 10000;
                            returnMoney = 13;
                        }
                    }
                    else
                    {
                        if (money * 0.0001 >= 0 && money * 0.0001 <= 0.3)
                        {
                            returnMoney = money * 0.0001 + 0.5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 0.3 && money * 0.0001 <= 2)
                        {
                            returnMoney = 0.412 * money * 0.0001 + 0.676;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 2 && money * 0.0001 <= 10)
                        {
                            returnMoney = 0.0625 * money * 0.0001 + 1.375;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 10 && money * 0.0001 <= 50)
                        {
                            //returnMoney = 2 * 10000;
                            returnMoney = 2;
                        }
                    }
                    txtStandard.Text = Math.Round(returnMoney * Industry * Difficulty, 2, MidpointRounding.AwayFromZero).ToString();
                }
            }
        }
        private void NewMethod2()
        {
            if (Session["rd"] != null || Session["td"] != null)
            {
                if (Session["tb"].ToString() == "")
                {
                    Jscript.Alert("本项目还没有总投资数，无法计算！", this);
                }
                else
                {
                    int type = (int)Session["rd"];//这个是用来判断是报告书还是报告表 这里我定义报告书为1
                    double money = Convert.ToDouble(Session["tb"]);		//这个是项目资金
                    double returnMoney = 0;	//这个是返回的项目金额
                    double Industry = 1.0;//行业系数
                    double Difficulty = 1;//难度系数
                    if (type == 1)
                    {
                        if (money * 0.0001 >= 0 && money * 0.0001 <= 0.3)
                        {
                            returnMoney = 2.333 * money * 0.0001 + 0.8;		//先用亿计算
                            //returnMoney = returnMoney * 10000;	//计算之后乘以10000吧亿化成万的单位
                        }
                        else if (money * 0.0001 > 0.3 && money * 0.0001 <= 2)
                        {
                            returnMoney = 0.882 * money * 0.0001 + 1.235;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 2 && money * 0.0001 <= 10)
                        {
                            returnMoney = 0.5 * money * 0.0001 + 2;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 10 && money * 0.0001 <= 50)
                        {
                            returnMoney = 0.05 * money * 0.0001 + 6.5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 50 && money * 0.0001 <= 100)
                        {
                            returnMoney = 0.08 * money * 0.0001 + 5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 100)
                        {
                            // returnMoney = 13 * 10000;
                            returnMoney = 13;
                        }
                    }
                    else
                    {
                        if (money * 0.0001 >= 0 && money * 0.0001 <= 0.3)
                        {
                            returnMoney = money * 0.0001 + 0.5;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 0.3 && money * 0.0001 <= 2)
                        {
                            returnMoney = 0.412 * money * 0.0001 + 0.676;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 2 && money * 0.0001 <= 10)
                        {
                            returnMoney = 0.0625 * money * 0.0001 + 1.375;
                            //returnMoney = returnMoney * 10000;
                        }
                        else if (money * 0.0001 > 10 && money * 0.0001 <= 50)
                        {
                            //returnMoney = 2 * 10000;
                            returnMoney = 2;
                        }
                    }
                    txtStandard.Text = Math.Round(returnMoney * Industry * Difficulty, 2, MidpointRounding.AwayFromZero).ToString();
                    txtApproved.Text = Math.Round(returnMoney * Industry * Difficulty, 2, MidpointRounding.AwayFromZero).ToString();
                }
            }
        }
        #endregion

        #region 生成合同
        protected void Button5_Click(object sender, EventArgs e)
        {
            if (XIANGMU.ProAcceptance())
            {
                Jscript.Alert("正式受理成功!", this);
                ShowProcessing();
            }
            else
                Jscript.Alert("正式受理失败!", this);
        }
        #endregion

        #region 项目退回/项目删除
        //项目退回
        protected void Button6_Click(object sender, EventArgs e)
        {

            //if (BLL.HuanJing.EditTable("UPDATE tbs001_developprojectbasicinfo t SET t.shoulituihuishanchu=2,projectreportstate=0 WHERE t.ProjectName LIKE '" + Session["pjName"].ToString() + "' ") > 0)
            if (BLL.HuanJing.EditTable("UPDATE tbs001_developprojectbasicinfo t SET t.shoulituihuishanchu=2,projectreportstate=0,t.nanduxishu='',t.hangyexishu='',t.biaozhunhetongjine='',t.hesuanren='',t.hetongdate='',t.hedinghetongjine='',t.hdpgjer ='',t.hyxsbqd ='" + 3 + "' WHERE t.ProjectName LIKE '" + Session["pjName"].ToString() + "' ") > 0)
            {
                Jscript.Alert("项目退回成功!", this);
                ShowProcessing();
            }
            else
            {
                Jscript.Alert("项目退回失败!", this);
            }
        }
        //项目删除
        protected void Button7_Click(object sender, EventArgs e)
        {
            if (BLL.HuanJing.EditTable("delete from tbs001_developprojectbasicinfo WHERE ProjectName LIKE '%" + Session["pjName"].ToString() + "%'") > 0)
            {
                Jscript.Alert("项目删除成功!", this);
                ShowProcessing();
            }
            else
            {
                Jscript.Alert("项目删除失败!", this);
            }
        }
        #endregion

        #region 专家会议=>徐金焘

        //设定会议时间
        protected void Button15_Click(object sender, EventArgs e)
        {
            Hashtable hs = new Hashtable();
            hs.Add("zhuanjiahuiyiriqiflag", pm0.Checked ? 2 : 1);
            hs.Add("zhuanjiahuiyichuliriqi", txtMeetingTime.Text.Trim());
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetMeetingDate(hs))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel6.Page, this.GetType(), "alert", "alert('设定会议时间成功！')", true);
                ShowProcessing();
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel6.Page, this.GetType(), "alert", "alert('设定会议时间失败！')", true);
            }
        }

        //绑定专家会议数据
        private void BindZJHI()
        {
            if (Session["pjName"].ToString() != "")
            {
                DevelopprojectbasicinfoDataCollection lst = BLL.HuanJing.GetZhuanJiaHuiYiInfo(Session["pjName"].ToString());
                if (lst.Count > 0)
                {
                    labConfirmMeeting.Text = "";
                    txtMeetingTime.Text = lst[0].huiyishijian;
                    txtMeetingPlace.Text = lst[0].zhuanjiahuiyididian;
                    txtMeetingExpert.Text = lst[0].zhuanjiahuiyizhuanjian;
                    //会议日期已确认(段云海)2012-01-03|已处理(常晓宇)2012-01-06|已确认(段云海)2012-01-05
                    if (lst[0].huiyishijian != null && lst[0].huiyishijian != "")
                    {
                        labConfirmMeeting.Text = labConfirmMeeting.Text + "会议日期已确认(" + lst[0].zhuanjiahuiyiriqiquerenren + ")" + lst[0].zhuanjiahuiyiriqiquerenriqi + "|";
                        Button15.Enabled = false;
                        txtMeetingTime.Enabled = false;
                        txtMeetingPlace.Enabled = false;
                        txtMeetingExpert.Enabled = false;
                    }
                    if (lst[0].zhuanjiahuiyichuliren != null && lst[0].zhuanjiahuiyichuliren != "")
                    {
                        labConfirmMeeting.Text = labConfirmMeeting.Text + "已处理(" + lst[0].zhuanjiahuiyichuliren + ")" + lst[0].zhuanjiahuiyichuliriqi + "|";
                    }
                    if (lst[0].zhuanjiahuiyiquerenren != null && lst[0].zhuanjiahuiyiquerenren != "")
                    {
                        labConfirmMeeting.Text = labConfirmMeeting.Text + "已确认(" + lst[0].zhuanjiahuiyiquerenren + ")" + lst[0].zhuanjiahuiyiquerenriqi;
                    }
                    if (lst[0].huiyiqueren == 1)
                    {
                        Button16.Enabled = false;
                    }
                    else
                    {
                        Button16.Enabled = true;
                    }

                }
            }
        }

        //专家会议确认
        protected void Button16_Click(object sender, EventArgs e)
        {
            Hashtable hs = new Hashtable();
            hs.Add("zhuanjiahuiyididian", txtMeetingPlace.Text.Trim());
            hs.Add("zhuanjiahuiyizhuanjian", txtMeetingExpert.Text.Trim());
            if (EnvironmentManagerSystem.BLL.XIANGMU.MeetingConfirm(hs))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel6.Page, this.GetType(), "alert", "alert('专家会议确认成功！')", true);
                ShowProcessing();
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel6.Page, this.GetType(), "alert", "alert('专家会议确认失败！')", true);
            }
        }

        #endregion

        #region 项目考评=>徐金焘

        //绑定项目考评数据
        private void BindXMKP()
        {
            if (Session["pjName"].ToString() != "")
            {
                DevelopprojectbasicinfoDataCollection lst = BLL.HuanJing.GetXiangMuKaoPingInfo(Session["pjName"].ToString());
                if (lst != null && lst.Count > 0)
                {
                    TextBox22.Text = lst[0].chugaokaoping;
                    TextBox23.Text = lst[0].zhonggaokaoping;
                    //环评单位考评
                    //TextBox24.Text = lst[0].huanpingdanweikaoping;
                    if (lst[0].chugaokaoping != null && lst[0].chugaokaoping != "")
                    {
                        Button21.Enabled = false;
                        TextBox22.Enabled = false;
                        TextBox23.Enabled = false;
                        //环评单位考评
                        //TextBox24.Enabled = false;
                    }
                    else
                    {
                        Button21.Enabled = true;
                        TextBox22.Enabled = true;
                        TextBox23.Enabled = true;
                        //环评单位考评
                        //TextBox24.Enabled = true;
                    }
                    if (lst[0].xiangmukaopingchuliren != null && lst[0].xiangmukaopingchuliren != "")
                    {
                        TextBox22.Enabled = false;
                        TextBox23.Enabled = false;
                        //环评单位考评
                        //TextBox24.Enabled = false;
                    }
                    else
                    {
                        TextBox22.Enabled = true;
                        TextBox23.Enabled = true;
                        //环评单位考评
                        //TextBox24.Enabled = true;
                    }
                    labXiangMuKaoPing.Text = "";
                    if (lst[0].xiangmukaopingchuliren != null && lst[0].xiangmukaopingchuliren != "")
                    {
                        labXiangMuKaoPing.Text = "已处理(" + lst[0].xiangmukaopingchuliren + ")" + lst[0].xiangmukaopingchuliriqi;
                    }

                }
            }
        }

        //项目考评确认
        protected void Button21_Click(object sender, EventArgs e)
        {
            Hashtable hs = new Hashtable();
            hs.Add("chugaokaoping", TextBox22.Text.Trim());
            hs.Add("zhonggaokaoping", TextBox23.Text.Trim());
            //环评单位考评
            //hs.Add("huanpingdanweikaoping", TextBox24.Text.Trim());
            if (EnvironmentManagerSystem.BLL.XIANGMU.AppraisalConfirm(hs))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel6.Page, this.GetType(), "alert", "alert('项目考评确认成功！')", true);
                ShowProcessing();
            }
            else
            {
                ScriptManager.RegisterStartupScript(UpdatePanel6.Page, this.GetType(), "alert", "alert('项目考评确认失败！')", true);
            }
        }

        #endregion

        #region 盛金龙----复审会议

        //复审会议
        protected void CheckBox6_CheckedChanged(object sender, EventArgs e)
        {
            tb.Visible = cbofs.Checked;
        }




        /// <summary>
        /// 验证控件
        /// </summary>
        public bool check()
        {
            bool bol = true;
            try
            {
                if (time.Text.Length <= 0) bol = false;
                else if (txtdidian.Text.Length <= 0) bol = false;
                else if (txtshuoming.Text.Length <= 0) bol = false;
                if (!bol) ScriptManager.RegisterStartupScript(UpdatePanel2.Page, this.GetType(), "alert", "alert('输入有空值')", true);
                return bol;
            }
            catch { return false; }
        }

        //确认
        protected void Button19_Click(object sender, EventArgs e)
        {
            bool result = false;
            DevelopprojectbasicinfoData model = new DevelopprojectbasicinfoData();
            if (!cbofs.Checked)
            {
                foreach (ListItem cb in CheckBoxList1.Items)
                {
                    if (cb.Selected == true)
                        model.pingguyijianxiangmuzhuangtai += cb.Value + ",";
                }
                if (model.pingguyijianxiangmuzhuangtai != string.Empty && model.pingguyijianxiangmuzhuangtai != null)
                    model.pingguyijianxiangmuzhuangtai = model.pingguyijianxiangmuzhuangtai.TrimEnd(',');
                //model.yijianbeizhu = txtbeizhu.Text.Trim();
                model.huiyipingshenjieguo = ddlResult.Text;
                if (txtshuoming.Text.Trim() != string.Empty)
                    model.buhegeshuoming = txtshuoming.Text.Trim();
                foreach (ListItem li in listtiaokuan.Items)
                {
                    if (li.Selected == true)
                        model.buhegetiaokuan += li.Value + ",";
                }
                if (model.buhegetiaokuan != null)
                    model.buhegetiaokuan = model.buhegetiaokuan.TrimEnd(',');
                result = EnvironmentManagerSystem.BLL.XIANGMU.SetOpinion(model);
            }
            if (cbofs.Checked && check())
            {
                model.shangwu = am.Checked ? 1 : 0;
                model.xiawu = pm.Checked ? 1 : 0;
                model.pingguyijianhuiyiriqi = time.Text;
                model.pingguyijianhuiyididian = txtdidian.Text.Trim();
                model.fushenhuiyipingshenjieguo = ddlfushenResult.Text;
                result = EnvironmentManagerSystem.BLL.XIANGMU.SetFuShen(model);
            }
            if (result)
            {
                ScriptManager.RegisterStartupScript(UpdatePanel2.Page, this.GetType(), "alert", "alert('确认成功')", true);
                ShowProcessing();
            }
        }
        //返回
        protected void Button18_Click(object sender, EventArgs e)
        {
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetCel())
            {
                ScriptManager.RegisterStartupScript(UpdatePanel2.Page, this.GetType(), "alert", "alert('返回成功')", true);
            }

        }

        #endregion

        #region 盛金龙----现场踏查

        //设定踏查
        protected void Button12_Click(object sender, EventArgs e)
        {
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetTCRQ(txtLookDate.Text.Trim()))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel3.Page, this.GetType(), "alert", "alert('踏查日期设定成功')", true);
                ShowProcessing();
            }
        }

        //确定踏查
        protected void Button13_Click(object sender, EventArgs e)
        {
            Hashtable hs = new Hashtable();
            hs.Add("tachadidian", txtLookPlace.Text.Trim());
            hs.Add("tachazhuanjia", input2zhuanjia.Value.Trim());
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetTCQD(hs))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel3.Page, this.GetType(), "alert", "alert('已确定')", true);
                ShowProcessing();
            }
        }

        //上传踏查数据
        protected void LinkButton3_Click(object sender, EventArgs e)
        {

        }

        //退回
        protected void Button11_Click(object sender, EventArgs e)
        {
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetTCTH())
            {
                Button11.Enabled = false;
                Button13.Enabled = false;
                Button16.Enabled = false;
                Button19.Enabled = false;
                Button21.Enabled = false;
                Button22.Enabled = false;
                Button14.Enabled = false;
                ScriptManager.RegisterStartupScript(UpdatePanel3.Page, this.GetType(), "alert", "alert('已退回')", true);
            }
            ShowProcessing();
        }
        #endregion

        #region 盛金龙----项目负责人

        public void BindFuzeren(string Deparatment)
        {
            ddlHead.DataSource = EnvironmentManagerSystem.BLL.XIANGMU.GetFuzeren(Deparatment);
            ddlHead.DataTextField = "UserName";
            ddlHead.DataValueField = "ID";
            ddlHead.DataBind();
            this.ddlHead.Items.Insert(0, new ListItem("待定", "待定"));
        }

        //确认
        protected void Button9_Click(object sender, EventArgs e)
        {
            Hashtable hs = new Hashtable();
            hs.Add("fuzeren", ddlHead.SelectedItem.Text.Trim());
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetXMQD(hs))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel4.Page, this.GetType(), "alert", "alert('已确定')", true);
                ShowProcessing();
            }
        }

        //退回
        protected void Button10_Click(object sender, EventArgs e)
        {
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetXMTH())
            {
                ScriptManager.RegisterStartupScript(UpdatePanel4.Page, this.GetType(), "alert", "alert('已退回')", true);
                ShowProcessing();
            }
        }
        #endregion

        #region 盛金龙----部门分配

        protected void Button8_Click(object sender, EventArgs e)
        {
            Hashtable hs = new Hashtable();
            hs.Add("hantacha", Convert.ToInt32(hantacha.Checked));
            hs.Add("hanhuiyi", Convert.ToInt32(hanhuiyi.Checked));
            hs.Add("lvsetongdao", Convert.ToInt32(lvsetongdao.Checked));
            hs.Add("biangengxiangmu", Convert.ToInt32(biangengxiangmu.Checked));
            //预审项目
            //hs.Add("yushenxiangmu", Convert.ToInt32(yushenxiangmu.Checked));
            hs.Add("txtbumen", txtbumen.Text.Trim());
            if (EnvironmentManagerSystem.BLL.XIANGMU.SetBM(hs))
            {
                ScriptManager.RegisterStartupScript(UpdatePanel5.Page, this.GetType(), "alert", "alert('操作成功')", true);
                ShowProcessing();
            }
        }

        #endregion

        #region 王洪涛----项目日志
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (txtLog.Text.Trim() == string.Empty)
            {
                Jscript.Alert("请输入项目日志！", this);
                return;
            }
            bool result = XIANGMU.UpdateProjectLog(txtLog.Text.Trim());
            if (!result)
                Jscript.Alert("项目日志保存失败！", this);
            else
                ShowProcessing();
        }
        #endregion

        #region 王洪涛----评估不合格说明

        /// <summary>
        /// 评估不合格说明的显示控制
        /// </summary>
        protected void DisplayExplain()
        {
            switch (ddlResult.SelectedIndex)
            {
                case 3:
                    Label3.Visible = true;
                    Label4.Visible = true;
                    Panel1.Visible = true;
                    txtshuoming.Visible = true;
                    break;
                default:
                    Label3.Visible = false;
                    Label4.Visible = false;
                    Panel1.Visible = false;
                    txtshuoming.Visible = false;
                    break;
            }
        }
        #endregion

        #region DropDownListBind
        public void DropDownListBind()
        {
            /// <summary>
            /// 项目状态
            /// </summary>
            CheckBoxList1.DataSource = EnvironmentManagerSystem.BLL.BasicData.GetProjectState();
            CheckBoxList1.DataTextField = "DataValue";
            CheckBoxList1.DataValueField = "ID";
            CheckBoxList1.DataBind();
            /// <summary>
            /// 原则性不合格条款
            /// </summary>
            listtiaokuan.DataSource = EnvironmentManagerSystem.BLL.BasicData.GetYuanZeXingBuHeGeTiaoKuanAll();
            listtiaokuan.DataTextField = "DataValue";
            listtiaokuan.DataValueField = "ID";
            listtiaokuan.DataBind();
            /// <summary>
            /// 难度系数
            /// </summary>
            txtDifficulty.DataSource = EnvironmentManagerSystem.BLL.BasicData.GetNanDuXiaShuAll();
            txtDifficulty.DataTextField = "DataValue";
            txtDifficulty.DataValueField = "DataValue";
            txtDifficulty.DataBind();
            foreach (ListItem item in txtDifficulty.Items)
            {
                if (Convert.ToDouble(item.Text) == 1)
                    item.Selected = true;
            }
            /// <summary>
            /// 行业系数
            /// </summary>
            txtIndustry.DataSource = EnvironmentManagerSystem.BLL.BasicData.GetHangYeXiaShuAll();
            txtIndustry.DataTextField = "DataValue";
            txtIndustry.DataValueField = "DataValue";
            txtIndustry.DataBind();
            foreach (ListItem item in txtIndustry.Items)
            {
                if (Convert.ToDouble(item.Text) == 1)
                    item.Selected = true;
            }
            /// <summary>
            /// 汇总上报材料
            /// </summary>
            cblistMaterial.DataSource = EnvironmentManagerSystem.BLL.BasicData.GetXiangMuShangBaoAll();
            cblistMaterial.DataTextField = "DataValue";
            cblistMaterial.DataValueField = "ID";
            cblistMaterial.DataBind();
            /// <summary>
            /// 项目执行部门
            /// </summary>
            txtbumen.DataSource = EnvironmentManagerSystem.BLL.ExecutiveDepartmentService.GetExecutiveDepartmentAll();
            txtbumen.DataTextField = "ed_Name";
            txtbumen.DataValueField = "ed_Name";
            txtbumen.DataBind();
            this.txtbumen.Items.Insert(0, new ListItem("待定", "待定"));
        }
        #endregion

        #region ceshi
        protected void ChoiceLookExpert(object sender, EventArgs e)   //这是触发的事件，接受来自div的值，并传递给input
        {
            string LookExpert = string.Empty;
            foreach (RepeaterItem ri in rep.Items)
            {
                CheckBox cb = ri.FindControl("checkbox1") as CheckBox;
                if (cb.Checked)//这个是被选择的项
                    LookExpert += cb.Text + ";";
            }
            input2zhuanjia.Value = LookExpert.TrimEnd(';');
        }

        protected void ChoiceMeetingExpert(object sender, EventArgs e)   //这是触发的事件，接受来自div的值，并传递给input
        {
            string MeetingExpert = string.Empty;
            foreach (RepeaterItem ri in Repeater1.Items)
            {
                CheckBox cb = ri.FindControl("checkbox1") as CheckBox;
                if (cb.Checked)//这个是被选择的项
                    MeetingExpert += cb.Text + ";";
            }
            txtMeetingExpert.Text = MeetingExpert.TrimEnd(';');
        }
        /// <summary>
        /// 绑定专家
        /// </summary>
        public void binds()
        {
            rep.DataSource = EnvironmentManagerSystem.BLL.Expert.GetAll();
            rep.DataBind();
            Repeater1.DataSource = EnvironmentManagerSystem.BLL.Expert.GetAll();
            Repeater1.DataBind();
        }
        #endregion

        #region 汇总上报确认/汇总上报保存
        // 汇总上报确认
        protected void Button14_Click(object sender, EventArgs e)
        {
            string Material = string.Empty;
            foreach (ListItem item in cblistMaterial.Items)
            {
                if (item.Selected == true)
                    Material += item.Value + ",";
            }
            Material = Material.TrimEnd(',');
            if (XIANGMU.ReportOK(Material))
            {
                ShowProcessing();
                Jscript.Alert("确认成功！", this);
            }
        }
        //汇总上报保存
        protected void Button22_Click(object sender, EventArgs e)
        {
            string Material = string.Empty;
            foreach (ListItem item in cblistMaterial.Items)
            {
                if (item.Selected == true)
                    Material += item.Value + ",";
            }
            Material = Material.TrimEnd(',');
            if (XIANGMU.ReportSave(Material))
            {
                ShowProcessing();
                Jscript.Alert("保存成功！", this);
            }
        }
        #endregion

        #region SelectedIndexChanged
        protected void list2_SelectedIndexChanged(object sender, EventArgs e)
        {
            DisplayExplain();
        }
        protected void txtbumen_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (txtbumen.SelectedIndex != 0)
                BindFuzeren(txtbumen.Text);
        }
        #endregion

        #region 上传评估报告/上传复审会议专家组评估意见
        #region 上传评估报告
        //上传评估报告
        protected void LinkButton3_Click1(object sender, EventArgs e)
        {
            this.lbl1.Text = UploadFile(ImageZ, LinkButton3);
            if (lbl1.Text != "")
            {
                XIANGMU.UploadReport(lbl1.Text, "pinggubaogaoURL");
                ShowProcessing();
            }
        }
        private string UploadFile(FileUpload fileUpload, LinkButton linkButton)
        {
            string fileUrl = "";
            if (fileUpload.HasFile)
            {
                //存储路径
                string strFilePath2 = "UploadFile/";
                //上传大小,单位M 
                string strFileExt1 = "50";
                int strFileSize1 = Convert.ToInt32(strFileExt1) * 1024 * 1024;
                //用这一行代码获得扩展名时，会多加一个点，比如.png，所以要把这个点去掉
                string newExt1 = Path.GetExtension(fileUpload.FileName).Replace(".", "");
                try
                {
                    //检查文件大小
                    if (fileUpload.PostedFile.ContentLength > strFileSize1)
                    {
                        Jscript.Alert("上传文件大小超过限制！", this);
                        return fileUrl;
                    }
                    //按当前时间重命名文件，以免上传同名文件   
                    string newName = Session["pjName"].ToString() + linkButton.Text + "." + newExt1;
                    fileUpload.PostedFile.SaveAs(Server.MapPath(strFilePath2 + newName));
                    fileUrl = "UploadFile/" + newName;
                    Jscript.Alert("文件上传成功！", this);
                    return fileUrl;
                }
                catch (Exception ex)
                {
                    Jscript.Alert("文件上传失败！", this);
                    return fileUrl;
                }
            }
            else
            {
                Jscript.Alert("请选择上传文件！", this);
                return fileUrl;
            }
        }
        #endregion

        #region 上传复审会议专家组评估意见
        //protected void LinkButton2_Click(object sender, EventArgs e)
        //{
        //    this.lbl2.Text = UploadFile(ImageZ1, LinkButton2);
        //    if (lbl2.Text != "")
        //    {
        //        XIANGMU.UploadReport(lbl2.Text, "fushenpingguyijianURL");
        //        ShowProcessing();
        //    }
        //}
        #endregion

        #region  上传专家评估意见
        //protected void LinkButton1_Click(object sender, EventArgs e)
        //{
        //    this.lbl3.Text = UploadFile(ImageZ2, LinkButton1);
        //    if (lbl3.Text != "")
        //    {
        //        XIANGMU.UploadReport(lbl3.Text, "pingguyijianURL");
        //        ShowProcessing();
        //    }
        //}
        #endregion
        #endregion

        #region CheckBox_CheckedChanged
        protected void hantacha_CheckedChanged(object sender, EventArgs e)
        {
            looking.Visible = hantacha.Checked;
        }
        protected void hanhuiyi_CheckedChanged(object sender, EventArgs e)
        {
            meeting.Visible = hanhuiyi.Checked;
        }
        #endregion

        #region 合同下载/下载评估报告/下载复审会议评估意见/下载专家评估意见
        /// <summary>
        /// 合同下载
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButton4_Click(object sender, EventArgs e)
        {
            DataTable dt = XIANGMU.GetProjectInfo();
            OfficeHelper.updateContract(this, dt);
            OfficeHelper.DownFile(this, Server.MapPath(Session["pjName"].ToString() + ".xls"));
        }
        /// <summary>
        /// 下载评估报告
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButton5_Click(object sender, EventArgs e)
        {
            DataTable dt = XIANGMU.GetProjectInfo();
            OfficeHelper.DownFile1(this, Server.MapPath(dt.Rows[0]["pinggubaogaoURL"].ToString()));
        }
        /// <summary>
        /// 下载复审会议评估意见
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButton6_Click(object sender, EventArgs e)
        {
            DataTable dt = XIANGMU.GetProjectInfo();
            OfficeHelper.DownFile1(this, Server.MapPath(dt.Rows[0]["fushenpingguyijianURL"].ToString()));
        }
        /// <summary>
        /// 下载专家评估意见
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LinkButton7_Click(object sender, EventArgs e)
        {
            DataTable dt = XIANGMU.GetProjectInfo();
            OfficeHelper.DownFile1(this, Server.MapPath(dt.Rows[0]["pingguyijianURL"].ToString()));
        }
        #endregion

        #region 行业调整系数/敏感程度调整系数(x)
        //行业调整系数
        protected void txtIndustry_SelectedIndexChanged(object sender, EventArgs e)
        {
            NewMethod0();
        }
        //敏感程度调整系数
        protected void txtDifficulty_SelectedIndexChanged(object sender, EventArgs e)
        {
            NewMethod0();
        }
        #endregion

        #region CheckBox2_CheckedChanged(x)
        protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
        {
            if (CheckBox2.Checked == true)
            {
                cb2.Enabled = true;
                if (BLL.HuanJing.EditTable("UPDATE tbs001_developprojectbasicinfo t SET t.hyxsbqd ='" + 2 + "' WHERE t.ProjectName LIKE '" + Session["pjName"].ToString() + "';") > 0)
                {

                }
            }
            //ShowProcessing();
        }
        #endregion
    }
}